/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import { rdOrganizeProjLineStatusDictData } from "./common.tsx";
import MaDictRadio from "@/components/ma-dict-picker/ma-dict-radio.vue";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { page as getZoneList } from "@/plugins/ai-warning/organization/api/rdOrganizeZone.ts";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "项目名称",
      prop: "name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "项目名称" }) },
    },
    {
      label: "所属区域",
      prop: "zone_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getZoneList,
        apiParams: {
          page: 1,
          pageSize: 1000,
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((zone: any) => ({
              label: zone.name,
              value: zone.id,
            }));
          }
          return [];
        },
        placeholder: t("form.pleaseSelect", { msg: "所属区域" }),
        filterable: true,
        clearable: true,
      },
    },
    {
      label: "状态",
      prop: "status",
      render: () => MaDictRadio,
      renderProps: {
        multiple: false,
        data: rdOrganizeProjLineStatusDictData(),
      },
    },
  ];
}
